package org.soarsky.wealthchengdu.module.comment;

import java.util.ArrayList;
import java.util.List;

import org.soarsky.wealthchengdu.R;
import org.soarsky.wealthchengdu.entity.CommentData;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CommentAdapter extends BaseAdapter {
	private Context context;
    public List<CommentData> commentList = new ArrayList<CommentData>();
	public CommentAdapter(Context context) {
		this.context = context;
	}

	public void setlistdata(List<CommentData> listdata)
	{
		this.commentList = listdata;
		this.notifyDataSetChanged();
	}
	
	@Override
	public int getCount() {
		return commentList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HolderView holderview = null;
		if (convertView == null) {
			holderview = new HolderView();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.com_listview, null);
			holderview.tv_lift = (TextView) convertView
					.findViewById(R.id.com_adapter_tv_lift);
			holderview.tv_right = (TextView) convertView
					.findViewById(R.id.com_adapter_tv_right);
			holderview.tv_text = (TextView) convertView
					.findViewById(R.id.com_adapter_tv_text);

			// holderview.imageBtn.setBackgroundResource(this.image[position]);
			// holderview.textview.setText(intn(position) +
			// this.view[position]);

			convertView.setTag(holderview);
		} else {
			holderview = (HolderView) convertView.getTag();
		}
		holderview.tv_lift.setText(commentList.get(position).getNickName());
		holderview.tv_right.setText(commentList.get(position).getAddTime());
		holderview.tv_text.setText(commentList.get(position).getContent());
		return convertView;
	}

	class HolderView {
		TextView tv_lift, tv_right, tv_text;
	}
}
